#include <iostream>
using std::cout;
using std::cin;
using std::endl;

#include <fstream>
using std::ifstream;
using std::ofstream;

#include <cstring>

const int MAX_CHARS_POR_LINEA = 512;
const int MAX_TERMINOS_POR_LINEA = 30;
const char* const DELIMITER = " ,.-?!;_[]*#\"()";

#include "Archivos.h"

Archivos::Archivos(char* entrada, char* salida) {
	 this->archivoEntrada = entrada;
	 this->archivoSalida = salida;
}

int parsear(){
	// create a file-reading object
	  ifstream fin;
	  fin.open(this.); // open a file
	  if (!fin.good())
	    return 1; // exit if file not found

	  // read each line of the file
	  int pepe=0;
	  ofstream fs("datasalida.txt");
	  int posicion =0;
	  while (!fin.eof())
	  {

	    char buf[MAX_CHARS_POR_LINEA];
	    fin.getline(buf, MAX_CHARS_POR_LINEA);


	    int n = 0; // a for-loop index

	    // array to store memory addresses of the tokens in buf
	    const char* token[MAX_CHARS_POR_LINEA] = {}; // initialize to 0

	    // parse the line
	    token[0] = strtok(buf, DELIMITER); // first token
	    if (token[0]) // zero if line is blank
	    {
	      for (n = 1; n < MAX_TERMINOS_POR_LINEA; n++)
	      {
			//isNumber();

			token[n] = strtok(0, DELIMITER);
	        if (!token[n]) break;
	      }
	    }

	    // process (print) the tokens
	    for (int i = 0; i < n; i++) {
	      fs << "Token[" << posicion << "] = " << token[i] << endl;
		  posicion++;
		}
	    cout << endl;
	  }
	  fs.close();
	  return 0;
}
